<?php $this->_extends('../_layouts/blank_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/multi-select-metro.css" rel="stylesheet" />
<link href="<?=Q::ini('custom_system/base_url')?>css/main.css?" rel="stylesheet" type="text/css" />
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.ui.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.ui.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url');?>js/validator.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/bootstrap.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/chosen.jquery.min.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jquery.multi-select.js"></script>   
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/select2.min.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jquery.input-ip-address-control-1.0.min.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/date.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/app.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/form-components.js"></script>
<script type="text/javascript">
$(function(){
	App.init();
	FormComponents.init();
	$("select[name='type']").change(function(){
		var provider_type = $("select[name='type']").val();
		if(provider_type == <?=Q::ini('custom_flag/product_provider_type/online/value')?>)
		{
			$("#online_type").show();
			$("input[name='wang_wang']").attr("require",true);
			$("input[name='wang_wang']").attr("disabled",false);
			$("input[name='link']").attr("require",true);
			$("input[name='link']").attr("disabled",false);
		}
		else
		{
			$("#online_type").hide();
			$("input[name='wang_wang']").val("");
			$("input[name='wang_wang']").attr("require",false);
			$("input[name='wang_wang']").attr("disabled","disabled");
			$("input[name='link']").val("");
			$("input[name='link']").attr("require",false);
			$("input[name='link']").attr("disabled","disabled");
		}
	});
});
</script>
<form action="<?=url('Product::Provider/EditSave');?>" method="post" onSubmit="return Validator.Validate(this,3)">
<table class="form_table">
		<tr>
			<th>名称</th>
			<td><input type="text" name="name" value="<?=$provider_detail['name'];?>" dataType="Custom" regexp="^(\S)+$" msg="供应商名称不能为空"/> <span class="red">*</span> </td>
			<th>跟进人员</th>
			<td>
				<select name="follow_user_id" dataType="Require" msg="请选择跟进人员">
					<option value="">请选择...</option>
					<? foreach($user as $u):?>
					<option value="<?=$u['id'];?>" <? if($provider_detail['follow_user_id'] == $u['id']):?>selected="selected"<? endif;?>><?=$u['name'];?></option>
					<? endforeach;?>
				</select>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<th>支付方式</th>
		    <td><input name="payment_method" type="text" value="<?=$provider_detail['payment_method'];?>" /></td>
			<th>付款期限（天）</th>
		    <td><input type="text" name="pay_deadline" value="<?=$provider_detail['pay_deadline'];?>" /></td>
		</tr>
		<tr>
			<th>联系人</th>
			<td ><input type="text" name="contact_person" value="<?=$provider_detail['contact_person'];?>" dataType="Custom" regexp="^(\S)+$" msg="联系人格式错误" /> <span class="red">*</span> </td>
			<th>QQ</th>
			<td><input type="text" name="qq" require="false" value="<?=$provider_detail['qq'];?>" /></td>
		</tr>
		<tr>
			<th>传真</th>
			<td><input type="text" name="fax" value="<?=$provider_detail['fax'];?>" require="false" dataType="Phone" msg="传真格式错误" /></td>
			<th>E-mail</th>
			<td><input type="text" name="email" value="<?=$provider_detail['email'];?>" require="false" dataType="Email" msg="E-mail格式错误"  /></td>
		</tr>
		<tr>
			<th>电话</th>
			<td><input type="text" name="phone" value="<?=$provider_detail['phone'];?>" dataType="Phone" msg="电话格式错误" /> <span class="red">*</span> </td>
			<th>手机</th>
			<td><input type="text" name="cellphone" value="<?=$provider_detail['cellphone'];?>" require="false" dataTypr="cellphone" msg="手机格式错误" /></td>
		</tr>
		<tr>
			<th>通讯地址</th>
			<td><input type="text" name="address" value="<?=$provider_detail['address'];?>" dataType="Custom" regexp="^(\S)+$" msg="通讯地址不能为空" /> <span class="red">*</span> </td>
			<th>供应商类型</th>
			<td>
				<select name="type" dataType="Require" msg="请选择供应商类型">
					<option value="" <?if($provider_detail['type'] == ''):?>selected="selected"<?endif;?>>请选择...</option>
					<?foreach (Q::ini('custom_flag/product_provider_type') as $pt):?>
					<option value="<?=$pt['value']?>" <? if($provider_detail['type'] == $pt['value']):?>selected="selected"<? endif;?>><?=$pt['name']?></option>
					<?endforeach;?>
				</select>
				<span class="red">*</span>
			</td>
		</tr>
		<tr id="online_type" <?if($provider_detail['type'] != Q::ini('custom_flag/product_provider_type/online/value')):?>style="display:none;"<?endif;?>>
			<th>旺旺号</th>
			<td><input type="text" name="wang_wang" value="<?=$provider_detail['wang_wang'];?>" <?if($provider_detail['type'] != Q::ini('custom_flag/product_provider_type/online/value')):?>disabled="disabled" require="false"<?else:?> require="true" <?endif;?> dataType="Custom" regexp="^(\S)+$" msg="旺旺号不能为空" /> <span class="red">*</span> </td>
			<th>店铺链接</th>
			<td><input type="text" name="link" value="<?=$provider_detail['link'];?>" <?if($provider_detail['type'] != Q::ini('custom_flag/product_provider_type/online/value')):?>disabled="disabled" require="false" <?else:?> require="true" <?endif;?> dataType="Url" msg="店铺链接格式不对" /> <span class="red">*</span> </td>
		</tr>
		<tr>
			<th>绑定分类</th>
			<td>
				<select id="my_multi_select2" name="product_categories_ids[]" multiple="multiple" dataType="Require" msg="请选择绑定的分类">
					<?foreach ($categories as $k => $c):?>
					<option value="<?=$k;?>" <?if (in_array($k, $provider_detail['mapping'])) echo "selected='selected'"?>><?=$c['name']?></option>
					<?endforeach;?>
				</select>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td><input type="hidden" name="id" value="<?=$provider_detail['id'];?>" /></td>
			<td><input type="submit" class="button" value="修改供应商" /></td>
		</tr>
</table>
</form>
<?php $this->_endblock();?>
